import org.apache.storm.Config;
import org.apache.storm.LocalCluster;
import org.apache.storm.StormSubmitter;
import org.apache.storm.generated.AlreadyAliveException;
import org.apache.storm.generated.AuthorizationException;
import org.apache.storm.generated.InvalidTopologyException;
import org.apache.storm.topology.TopologyBuilder;

public class Topology {

    public static void main(String[] args) throws AlreadyAliveException, InvalidTopologyException, AuthorizationException {
        TopologyBuilder builder = new TopologyBuilder();
        //用于处理order表中的数据
        builder.setSpout("spout", new spout1());
        builder.setBolt("bolt1", new bolt1()).shuffleGrouping("spout");
        builder.setBolt("bolt1_2", new bolt1_2()).shuffleGrouping("bolt1");
        //用于处理order_detail表中的数据
        builder.setSpout("spout2", new spout2());
        builder.setBolt("bolt2_1", new bolt2_1()).shuffleGrouping("spout2");
        builder.setBolt("bolt2_2", new bolt2_2()).shuffleGrouping("bolt2_1");

        //本地运行，用于调试
        LocalCluster localCluster = new LocalCluster();
        Config config = new Config();
        localCluster.submitTopology("topology1", config,builder.createTopology());
        //集群运行
        //Config config = new Config();
        //StormSubmitter.submitTopology("flume_test1", config, builder.createTopology());
    }
}